﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TSharp.Core.Authorization.Actors
{
    #region 注释
    /* ====================
     * 作者：wangyao
     * 创建时间：2013/5/24 8:54:40
     * ====================
     */
    #endregion
    /// <summary>
    /// 参与者基类，参与者可以为用户、角色、组织结构等
    /// </summary>
    [Serializable]
    public class Actor
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public Actor()
            : base()
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public Actor(Guid id, String code, String title)
            : base()
        {
            this.id = id;
            this.code = code;
            this.title = title;
        }

        #region 系统内置参与者主键常量定义

        /// <summary>
        /// 超级管理员用户主键，系统内置
        /// </summary>
        public const int AdminKey = 1;

        /// <summary>
        /// 超级管理员用户标识，系统内置
        /// </summary>
        public const string AdminCode = "Admin";

        /// <summary>
        /// 管理员角色主键，系统内置
        /// </summary>
        public const int AdminRoleKey = 2;

        /// <summary>
        /// 管理员角色标识，系统内置
        /// </summary>
        public const string AdminRoleCode = "AdminRole";

        /// <summary>
        /// 游客角色标识，系统内置
        /// </summary>
        public const int VisitorRoleKey = 3;

        /// <summary>
        /// 游客角色标识，系统内置
        /// </summary>
        public const string VisitorRoleCode = "AdminRole";

        /// <summary>
        /// 程序内置系统用户，具有所有操作权限，但不具有授权权限
        /// 该主键在用户表中不存在，没有用户ID，不能登录
        /// </summary>
        public const int SystemOperationKey = 200;

        /// <summary>
        /// 系统用户标识
        /// </summary>
        public const string SystemOperationCode = "SystemOperation";

        /// <summary>
        /// 系统用户名
        /// </summary>
        public const string SystemOperationName = "内置超级管理员";

        #endregion

        /// <summary>
        /// 参与者主键
        /// </summary>
        private Guid id;

        /// <summary>
        /// 参与者标识名称，同时是参与者的登录名
        /// </summary>
        private String code;

        /// <summary>
        /// 参与者的内部排序号，用于查询排序的时候使用
        /// </summary>
        private int order;

        /// <summary>
        ///  参与者的中文标识名称，主要是给用户标识的名称
        /// </summary>
        private String title;

        /// <summary>
        /// 主键
        /// </summary>
        public Guid Id
        {
            get
            {
                return id;
            }
            protected internal set
            {
                this.id = value;
            }
        }

        /// <summary>
        /// 参与者标识
        /// </summary>
        public string Code
        {
            get
            {
                return code;
            }
            protected set
            {
                this.code = value;
            }
        }

        /// <summary>
        /// 参与者名称
        /// </summary>
        public string Title
        {
            get
            {
                return title;
            }
            protected set
            {
                this.title = value;
            }
        }

        /// <summary>
        /// 排序
        /// </summary>
        public int Order
        {
            get
            {
                return order;
            }
            protected set
            {
                this.order = value;
            }
        }

        /// <summary>
        /// 获取所有系统用户主键
        /// </summary>
        public static List<int> GetAllSystemUserIds()
        {
            List<int> sysUserKeys = new List<int>(10);

            //TO DO:实现获取所有系统用户主键

            return sysUserKeys;
        }

        /// <summary>
        /// 获取所有系统角色
        /// </summary>
        /// <returns></returns>
        public static List<int> GetAllSystemRoleIds()
        {
            List<int> sysRoleKeys = new List<int>(10);

            //TO DO:实现获取所有系统角色主键

            return sysRoleKeys;
        }
    }
}
